package cn.tedu.jxc.service.impl;

import cn.tedu.jxc.ex.ServiceException;
import cn.tedu.jxc.mapper.CustomerMapper;
import cn.tedu.jxc.mapper.ProductSalesMapper;
import cn.tedu.jxc.pojo.dto.CustomerAddNewDTO;
import cn.tedu.jxc.pojo.dto.ProductSalesAddNewDTO;
import cn.tedu.jxc.pojo.entity.Customer;
import cn.tedu.jxc.pojo.entity.ProductSales;
import cn.tedu.jxc.pojo.vo.CustomerListVO;
import cn.tedu.jxc.pojo.vo.CustomerVO;
import cn.tedu.jxc.pojo.vo.SalesOrderListVO;
import cn.tedu.jxc.pojo.vo.UserSalesVO;
import cn.tedu.jxc.service.CustomerService;
import cn.tedu.jxc.service.ProductSalesService;
import cn.tedu.jxc.web.ServiceCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class ProductSalesServiceImpl implements ProductSalesService {
   @Autowired
    ProductSalesMapper productSalesMapper;

    @Override
    public void salesAdd(ProductSalesAddNewDTO productSalesAddNewDTO) {
        log.debug("开始处理[添加销售单]的业务,参数:{}",productSalesAddNewDTO);
        ProductSales productSales = new ProductSales();
        BeanUtils.copyProperties(productSalesAddNewDTO,productSales);
        productSales.setChecked(0);
        productSalesMapper.insert(productSales);
        log.debug("添加销售单完成,结果:{}",productSales);
    }

    @Override
    public List<UserSalesVO> selectUserNameList() {
        return productSalesMapper.selectUserNameList();
    }

    @Override
    public List<SalesOrderListVO> selectSalesOrderList() {
        log.debug("开始处理[查询销售单列表]的业务,无参数");
        List<SalesOrderListVO> salesOrderListVOS = productSalesMapper.selectSalesOrderList();
        log.debug("查询销售单列表完成,结果:{}",salesOrderListVOS);
        return salesOrderListVOS;
    }

}
